#ifndef ENMODULE_H
#define ENMODULE_H

#include <ThreadSafeQList.h>
#include <QHash>
#include <enbody.h>
#include <QGraphicsPixmapItem>
#include <QGraphicsScene>

/* This class acts as a thread safe container for content such as EnBody's and other structures allowing for fast switching between
  different scenes or views of content. Have a save state function that saves the settings of all the internal objects to
  a file that can be recalled later. */
class EnModule : public QObject
{
    Q_OBJECT

public:
    EnModule( QString uName );
    ~EnModule();
    //ThreadSafeQList<EnBody*> bodyList;
    QHash<QString,EnBody*> bodyMap;
    QString getBackgroundFileName();
    void setBackgroundFilename( QString b );
    void setBackgroundPixmap( QGraphicsPixmapItem* p );
    QGraphicsPixmapItem* getBackgroundPixmap();
    QBrush* getBackgroundBrush();
    const QImage getBackgroundImage();
    void setBackground( QString fileName );
    void localAddBody();
    void localRemoveBody( QGraphicsScene* scene, QString bodyMapKey );

public slots:
    //void networkAddBody();

signals:
    void bodyLocallyAdded( EnBody* body );
    void bodyLocallyRemoved( QString bodyMapKey );

private:
    QImage backgroundImage;
    QString backgroundFileName;
    QReadWriteLock rwLock;
    QGraphicsPixmapItem* backgroundPixmap;
    QBrush* backgroundBrush;
    QString userName;
};

#endif // ENMODULE_H
